import java.sql.*;
import com.genexus.ui.*;
import com.genexus.db.*;
import com.genexus.*;

public final class gxrgzc extends GXProcedure
{
   public gxrgzc( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( gxrgzc.class ), "" );
   }

   public gxrgzc( int remoteHandle ,
                  ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /*
         This program controls table creation either for the creation or
         reorganization processes.
         Rename auxiliary tables to the appropriate name.
      */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("rgzrnmtbl", new Object[] {"6"}) );
      GXReorganization.addMsg( localUtil.getMessages().getMessage("fileren", new Object[] {"GXA0052","MMMDA10"}) );
      cmdBuffer = " DROP TABLE [MMMDA10] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " {CALL sp_rename('[GXA0052]', 'MMMDA10')} ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " ALTER TABLE [MMMDA10] ADD PRIMARY KEY([ModCod]) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      /* Adding attributes to tables' structure. */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("rgzbldidx", new Object[] {"7"}) );
      /* Indices for table MMMDA10 */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"MMMDA11"}) );
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"MMMDA12"}) );
      cmdBuffer = " DROP INDEX [MMMDA10].[MMMDA12] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE NONCLUSTERED INDEX [MMMDA12] ON [MMMDA10] ([MarCodAux] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      /* Referential constraints on table MMMDA10 */
      /* Indices for table MMCLI30 */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("1001", new Object[] {"MMCLI30","MMCLI32"}) );
      cmdBuffer = " DROP INDEX [MMCLI30].[MMCLI32] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"IMMCLI30"}) );
      cmdBuffer = " DROP INDEX [MMCLI30].[IMMCLI30] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE NONCLUSTERED INDEX [IMMCLI30] ON [MMCLI30] ([ModCod] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"IMMCLI301"}) );
      cmdBuffer = " DROP INDEX [MMCLI30].[IMMCLI301] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE NONCLUSTERED INDEX [IMMCLI301] ON [MMCLI30] ([MarCod] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      /* Referential constraints on table MMCLI30 */
      /* Indices for table MMVEH10 */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("1001", new Object[] {"MMVEH10","MMVEH12"}) );
      cmdBuffer = " DROP INDEX [MMVEH10].[MMVEH12] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("1001", new Object[] {"MMVEH10","IMMVEH10"}) );
      cmdBuffer = " DROP INDEX [MMVEH10].[IMMVEH10] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("1001", new Object[] {"MMVEH10","IMMVEH101"}) );
      cmdBuffer = " DROP INDEX [MMVEH10].[IMMVEH101] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"MMVEH14"}) );
      cmdBuffer = " DROP INDEX [MMVEH10].[MMVEH14] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE NONCLUSTERED INDEX [MMVEH14] ON [MMVEH10] ([MVehCodCnv] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"MMVEH16"}) );
      cmdBuffer = " DROP INDEX [MMVEH10].[MMVEH16] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE NONCLUSTERED INDEX [MMVEH16] ON [MMVEH10] ([CmbCodCnv] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"MMVEH17"}) );
      cmdBuffer = " DROP INDEX [MMVEH10].[MMVEH17] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE NONCLUSTERED INDEX [MMVEH17] ON [MMVEH10] ([ModCod] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"MMVEH12"}) );
      cmdBuffer = " DROP INDEX [MMVEH10].[MMVEH12] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE NONCLUSTERED INDEX [MMVEH12] ON [MMVEH10] ([MarCod] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      /* Referential constraints on table MMVEH10 */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("rgzdroptbl", new Object[] {"8"}) );
      /* Dropping attributes from tables' structure. */
      /* Dropping removed tables */
      cleanup();
   }

   protected void cleanup( )
   {
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      cmdBuffer = "" ;
      /* GeneXus formulas. */
   }

   protected String cmdBuffer ;
}

